package com.websuites.webservice;

import java.util.HashMap;
import java.util.Map;

import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;

import org.apache.ws.security.WSPasswordCallback;

public class PasswordHandler implements CallbackHandler 
{

	private final Map<String,String> passwords = new HashMap<String,String>();

	public PasswordHandler() 
	{
		passwords.put("krcs", "wsuser");
		passwords.put("fengcp", "wsuser");
	}

	public void handle(Callback[] callbacks) 
	{
		WSPasswordCallback callback = (WSPasswordCallback)callbacks[0];
		String id = callback.getIdentifer();
		callback.setPassword((String)passwords.get(id));
	}
}
